/**
 * Project Name:mbr-pts-intf
 * File Name:ServiceException.java
 * Package Name:com.aeye.mbr.pts.intf.exception
 * Date:2015年8月21日下午3:21:28
 * Copyright (c) 2015, shengpeng@a-eye.cn All Rights Reserved.
 *
*/

package com.aeye.mbr.common.exception;

import com.aeye.mbr.common.base.constants.ErrorCodeConstants;

/**
 * ClassName:ServiceException <br/>
 * Function: service层异常对象<br/>
 * Reason:	 规范异常码和描述. <br/>
 * Date:     2015年8月21日 下午3:21:28 <br/>
 * @author   shengpeng
 * @version  
 * @since    JDK 1.6
 * @see 	 
 */
public class ServiceException extends RuntimeException{
	/**
	 * serialVersionUID:TODO(用一句话描述这个变量表示什么 )by shengpeng.
	 * @since JDK 1.6
	 */
	public ServiceException() {
		super();
	}
	private static final long serialVersionUID = 1L;
	private int code;
	private String message;
	private String causeStr;
	public ServiceException(ErrorCodeConstants ec)
	{
		super(ec.getDesc());
		this.code = ec.getVal();
		this.message = ec.getDesc();
	}
	public ServiceException(ErrorCodeConstants ec,String cause)
	{
		super(ec.getDesc() +"," +cause);
		this.code = ec.getVal();
		this.message = ec.getDesc() +"," +cause;
		this.causeStr = cause;
	}
	
	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	@Override
	public String toString() {
		return message + (null != causeStr ? ", " + causeStr : "");
	}
}

